"""
测试财务应付款搜索框搜索
"""
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

#打开浏览器
driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(30)
#打开crm
driver.get("http://192.168.1.25/crm")
sleep(1)
#准备数据
username = "admin"
password = "123456"
yfk_name = "keke"

#定位器
username_locator = (By.NAME,'name')
password_locator = (By.NAME,'password')
login_btn_locator = (By.NAME,'submit')
cw_locator = (By.LINK_TEXT,'财务')
yfk_btn_locator = (By.LINK_TEXT,'应付款')
sousuo_locator = (By.ID,'search')
sousuo_btn_locator = (By.CSS_SELECTOR,'#searchForm > ul > li:nth-child(4) > button')

#登录输入用户名和密码
driver.find_element(*username_locator).send_keys(username)
driver.find_element(*password_locator).send_keys(password)
sleep(1)
#点击登录
driver.find_element(*login_btn_locator).click()
sleep(1)
#点击财务
driver.find_element(*cw_locator).click()
sleep(1)
#点击应付款
driver.find_element(*yfk_btn_locator).click()
#搜索框输入想要搜索的数据
driver.find_element(*sousuo_locator).send_keys(yfk_name)
#点击搜索
driver.find_element(*sousuo_btn_locator).click()

#退出
sleep(2)
driver.quit()